const dataSourceEnum = {
    file: '文件',
    api: 'api接口',
    database: '数据库',
    web: '网页'
}
// 任务题库展示内容
const columns = {
    operation: {},
    dataSource: [
        {
            title: '序号',
            key: 'id',
        },
        {
            title: '数据源类型',
            key: 'data_source_type',
            render(row) {
                return dataSourceEnum[row['data_source_type']]
            },
        },
        {
            title: '数据源类别',
            key: 'category',
        },
        {
            title: '数据源名称',
            key: 'name',
        },
        {
            title: '资源类型',
            key: 'resource_type',
        },
        {
            title: '操作',
            align: "left",
            titleAlign: 'center',
            width: 300,
            key: 'actions',
            render(row) {
                // 操作列表
                let array = {
                    modify: '修改',
                    view: '查看',
                    del: '删除'
                }
                let list = [];
                for (let key in array) {
                    list.push(h(
                        'span',
                        {
                            class: 'span-button pointer',
                            onClick: () => columns.operation[key](row)
                        },
                        {default: () => array[key]}
                    ))
                }
                return list
            }
        }
    ],
    taskQuestionBank: [
        {
            title: '名称',
            key: 'name',
            width: 300
        },
        {
            title: '简介',
            width: 300,
            key: 'describe'
        },
        {
            title: '项目题库题数',
            key: 'questions_number',
            render(row) {
                // 当row['questions_number']为0时 返回 尚未上传题库
                return row['questions_number'] || '尚未上传题库';
            }
        },
        {
            title: '操作',
            align: "left",
            titleAlign: 'center',
            width: 300,
            key: 'actions',
            render(row) {
                // 操作列表
                let array = {
                    view: '查看',
                    upQuestionBank: '上传题库'
                }
                let list = [];
                for (let key in array) {
                    list.push(
                        h(
                            'span',
                            {
                                class: 'span-button pointer',
                                onClick: () => columns.operation[key](row)
                            },
                            {default: () => array[key]}
                        )
                    )
                }
                return list
            }
        }
    ]
}

export {columns}